package uit.nfcmenu.utils;

import java.util.ArrayList;

import uit.nfcmenu.models.IModel;
import uit.nfcmenu.models.MenuModel;


import android.util.Log;
import android.view.Menu;


public class Utilities {
	public static final String tag = Utilities.class.getSimpleName();
	
	public static void showLogList(String tag, ArrayList<MenuModel> addresses) {
		for (Object address : addresses) {
			Log.i(tag, "address: " + address.toString());
		}
	}
	
	public static String[] toStringList(ArrayList<IModel> addresses) {
		int n = addresses.size();
		String[] addressStrings = new String[n];
		for (int i=0; i < n; i++) {
			addressStrings[i] = addresses.get(i).toString();
		}
		return addressStrings;
	}

	public static ArrayList<MenuModel> getMainMenu(ArrayList<MenuModel> menus) {
		ArrayList<MenuModel> mainMenus = new ArrayList<MenuModel>();
		for (MenuModel menu : menus) {
			if (menu.getSubMenuID() == 0) {
				mainMenus.add(menu);
			}
		}
		return mainMenus;
	}
	
	public static ArrayList<MenuModel> getSubMenu(ArrayList<MenuModel> menus, int mainId) {
		ArrayList<MenuModel> subMenus = new ArrayList<MenuModel>();
		for (MenuModel menu : menus) {
			if (mainId != 0 && menu.getSubMenuID() == mainId) {
				subMenus.add(menu);
			}
		}
		return subMenus;
	}
	
	/*
	 * Convert
	 */

//	public static ArrayList<IModel> convertToIterface(
//			IModel[] selectItems) {
//		ArrayList<IModel> addressStrings = new ArrayList<IModel>();
//		for (IModel address : selectItems) {
//			addressStrings.add((IModel)address);
//		}
//		return addressStrings;
//	}
//	
//	public static ArrayList<IModel> convertToIterface(
//			ArrayList<ItemModel> selectItems) {
//		ArrayList<IModel> addressStrings = new ArrayList<IModel>();
//		for (IModel address : selectItems) {
//			addressStrings.add((IModel)address);
//		}
//		return addressStrings;
//	}
	
//	public static ArrayList<IModel> convertToIterface(
//			ArrayList<OrderModel> selectItems) {
//		ArrayList<IModel> addressStrings = new ArrayList<IModel>();
//		for (IModel address : selectItems) {
//			addressStrings.add((IModel)address);
//		}
//		return addressStrings;
//	}
}
